package com.itheima.admin.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.admin.dto.ChannelPageRequestDto;
import com.itheima.admin.dto.SensitivePageRequestDto;
import com.itheima.admin.mapper.AdSensitiveMapper;
import com.itheima.admin.pojo.AdChannel;
import com.itheima.admin.pojo.AdSensitive;
import com.itheima.admin.service.AdSensitiveService;
import com.itheima.common.vo.PageResultVo;
import org.springframework.stereotype.Service;


/**
 * @version 1.0
 * @description 敏感词的业务逻辑
 * @package com.itheima.admin.service
 */

@Service
public class AdSensitiveServiceImpl extends ServiceImpl<AdSensitiveMapper ,AdSensitive> implements AdSensitiveService {

    @Override
    public PageResultVo<AdSensitive> findPage(SensitivePageRequestDto dto) {

        //1.构建分页对象
        IPage<AdSensitive> page1 = new Page(dto.getPage(),dto.getSize());

        //2.构建查询对象
        LambdaQueryWrapper<AdSensitive> lwq = Wrappers.<AdSensitive>lambdaQuery();

                //3.追加=查询条件
                //3.1模糊查询   p1 = ture 时才执行查询
             lwq.like(StringUtils.isNotEmpty(dto.getName()),AdSensitive::getSensitives,dto.getName());

        //3.3 分页查询
        page(page1,lwq);

        //返回数据
        return PageResultVo.pageResult(dto.getPage(),dto.getSize(),page1.getTotal(),page1.getRecords());
    }


}
